package com.org.service.impl;

import com.org.constant.AgreementTypeEnum;
import com.org.constant.Params;
import com.org.form.AgreementInfoForm;
import com.org.mapper.AgreementDetailMapper;
import com.org.model.AgreementDetail;
import com.org.service.AgreementMgrService;
import com.org.service.facotry.AgreementFactory;
import com.org.service.facotry.AgreementService;
import com.org.util.ResponseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.Map;

/**
 * @author: vane.Q
 * @date: 2024/1/21 12:38
 */
@Repository
public class AgreementMgrServiceImpl implements AgreementMgrService {

    @Autowired
    private AgreementDetailMapper agreementDetailMapper;

    @Override
    public Map<String, Object> category() {
        Map<String, Object> success = ResponseUtils.success();
        success.put(Params.TYPE_LIST, AgreementTypeEnum.typeList());
        return success;
    }

    @Override
    public Map<String, Object> addAgreement(AgreementInfoForm form) {
        AgreementDetail agreementDetail = new AgreementDetail();
        agreementDetail.setAgreementNo(form.getAgreementNo());
        agreementDetail.setTitle(form.getTitle());
        agreementDetail.setAgreementType(form.getAgreementType());
        agreementDetail.setContent(form.getContent());
//        agreementDetail.setVersion(1);
        agreementDetail.setStatus(1);
        agreementDetail.setCreatedAt(new Date());
        agreementDetailMapper.save(agreementDetail);
        return ResponseUtils.success();
    }
}
